package com.ph.shopping.facade.duboresult;

import com.ph.shopping.common.core.customenum.ResultEnum;
import com.ph.shopping.common.util.result.Result;

public final class DubboResult {
	/**
	 * 
	* @Title: getResultByEnum  
	* @Description: TODO(这里用一句话描述这个方法的作用)  
	* @param @param dubboReturn
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getResultByEnum(ResultEnum dubboReturn) {
		Result result = new Result();
		if (dubboReturn != null) {
			result.setCode(dubboReturn.getCode());
			result.setMessage(dubboReturn.getMsg());
		}
		return result;
	}
	/**
	 * 
	* @Title: getResultByEnumOrRe  
	* @Description: TODO(这里用一句话描述这个方法的作用)  
	* @param @param dubboReturn
	* @param @param result
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getResultByEnumOrRe(ResultEnum dubboReturn,Result result){
		if(result == null)
			result = new Result();
		if(dubboReturn != null){
			result.setCode(dubboReturn.getCode());
			result.setMessage(dubboReturn.getMsg());
		}
		return result;
	}
	/**
	 * 
	* @Title: getResultBySuccess  
	* @Description: 返回成功值 
	* @param @param result
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getResultBySuccess(Result result) {
		if (result == null)
			result = new Result();
		return getResultByEnumOrRe(ResultEnum.SUCCESS, result);
	}
	/**
	 * 
	* @Title: getResultBySuccess  
	* @Description: 返回成功  
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getResultBySuccess() {
		
		return getResultByEnumOrRe(ResultEnum.SUCCESS, new Result());
	}
	/**
	 * 
	* @Title: getResultByError  
	* @Description: 返回  
	* @param @param result
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getResultByError(Result result) {
		if (result == null)
			result = new Result();
		return getResultByEnumOrRe(ResultEnum.MEMBER_UNKOWN_ERROR, result);
	}
	/**
	 * 
	* @Title: getDefResult  
	* @Description: service 默认返回值  
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getDefResult(){
		
		return DubboResult.getResultByEnum(ResultEnum.MEMBER_DATA_ERROR);
	}
	/**
	 * 
	* @Title: getDefResultByImpl  
	* @Description: impl 默认返回值  
	* @param @return    参数  
	* @return Result    返回类型  
	* @throws
	 */
	public static Result getDefResultByImpl() {

		return DubboResult.getResultByEnum(ResultEnum.MEMBER_NO_DATA);
	}
}
